package com.utils.script.ftp;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import sun.net.ftp.FtpClient;
import sun.net.ftp.FtpProtocolException;

public class FtpLink {
	
	/** 
     * 取得相对于当前连接目录的某个目录下所有文件列表 
     *  
     * @param path 
     * @return 
     * @throws FtpProtocolException 
     */  
    @SuppressWarnings("deprecation")
	public static List<Object> getFileList(FtpClient ftpClient,String path) throws FtpProtocolException{  
        List<Object> list = new ArrayList<Object>();  
        DataInputStream dis;  
        try {  
            dis = new DataInputStream(ftpClient.nameList( path));  
            String filename = "";  
            while((filename = dis.readLine()) != null){ 
            System.out.println(filename);	
//                list.add(filename);  
            }  
        } catch (IOException e) {  
            e.printStackTrace();  
        }  

        return list;  
    }  
    
    public static void main(String[] args) {
/*    	FtpClient ftpClient = connect("127.0.0.1",10022,"root","","/");
    	try {
			getFileList(ftpClient,"/");
		} catch (FtpProtocolException e) {
			System.out.println("gege");
			e.printStackTrace();
		}*/
	}
}
